/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.serializer;

import com.inspur.edp.cef.api.attr.CefDataAttribute;
import com.inspur.edp.cef.api.attr.RootAttribute;
import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
import com.inspur.edp.cef.gencommon.ReflectionUtils;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.ManagerGeneratorContext;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.CefDataSerGenContext;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.CefDataSerGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.deserializer.CefNodeDataDeserGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.deserializer.EntityNodeDataDeserGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.serializer.base.CefNodeDataSerGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.serializer.entity.EntityNodeDataSerGenerator;
import com.inspur.edp.cef.generator.repository.common.CefMgrTypeInfo;
import com.inspur.edp.das.commonmodel.IGspCommonModel;
import com.inspur.edp.das.commonmodel.IGspCommonObject;

import java.util.ArrayList;

public abstract class EntityDataSerGenerator extends CefDataSerGenerator {
    public EntityDataSerGenerator(ManagerGeneratorContext mgrContext) {
        super(mgrContext);
    }

    @Override
    protected EntityDataSerGenContext getDataSerGenContext() {
        return (EntityDataSerGenContext) super.getContext();
    }

    @Override
    protected CefDataSerGenContext createDataSerContext() {
        return new EntityDataSerGenContext(getMgrContext());
    }

    @Override
    protected final CefNodeDataSerGenerator createNodeDataSerGenerator() {
        IGspCommonObject mainObj = ((IGspCommonModel)getMgrContext().getProjContext().getCefGenContext().getMetadata().getContent()).getMainObject();
        return createEntityNodeDataSerClassGenerator(mainObj);
    }

    @Override
    protected final CefNodeDataDeserGenerator createNodeDataDeserGenerator() {
        IGspCommonObject mainObj = ((IGspCommonModel)getMgrContext().getProjContext().getCefGenContext().getMetadata().getContent()).getMainObject();
        return createEntityNodeDataDeserClassGenerator(mainObj);
    }

    protected abstract EntityNodeDataSerGenerator createEntityNodeDataSerClassGenerator(IGspCommonObject object);

    protected abstract EntityNodeDataDeserGenerator createEntityNodeDataDeserClassGenerator(IGspCommonObject object);
}
